<?php
session_start();
date_default_timezone_set('America/Los_Angeles');
include'connect_db.php';

if(!isset($_SESSION['user']))
	header("Location: login.php");

$user = mysql_real_escape_string($_SESSION['user']);
$result = mysql_query("SELECT * FROM user WHERE id = $user");
$row = mysql_fetch_array($result);

if($row['type'] != 2)
	die;

$id = mysql_real_escape_string($_POST['id']);

$result = mysql_query("SELECT * FROM login_history WHERE user = $id");

while($row = mysql_fetch_array($result))
{
	echo "<tr><td>".$row['ip']."</td>";
	echo "<td>".date("d M Y g:i:sA", $row['timestamp'])." PST</td></tr>";
}

?>